package cn.liujianbo.example.mystarter.config;

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;

import javax.annotation.PostConstruct;

/**
 * @author 刘建波
 * @date 2021-01-16 10:44
 */
@ConfigurationProperties(prefix = "test.user")
@Data
public class UserProperties implements InitializingBean {
    private String username;
    private String password;

    @PostConstruct
    public void postConstruct() {
        System.out.println("this = " + this);
        this.username = "张三";
        this.password = "2008";
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("this = " + this);
        this.username = "李四";
        this.password = "111";
    }
}
